<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../vue.js"></script>
</head>

<body>
    <div>
        数量：
        <input type="text" id="num" value="1" oninput="changNum()">
    </div>
    <div>
        单价：
        <input type="text" id="price" value="1" oninput="changPrice()">
    </div>
    <div>
        总计：<span id="tt"></span>
    </div>

    <script>
        var num = document.getElementById('num')
        var price = document.getElementById('price')
        var tt = document.getElementById('tt');

        tt.innerText = Number(num.value) * Number(price.value);

        function changNum() {
            var numVal = Number(num.value)
            tt.innerText = numVal * Number(price.value);
        }

        function changPrice() {
            var priceVal = Number(price.value);
            tt.innerText = Number(num.value) * priceVal
        }
    </script>
</body>

</html>